<?php

class Database extends PDO {

    //example class variables
    public $lastQuery;
    private $err;
    private $log;
    private static $_instance;

    //constructor for parent class
    public function __construct() {
        $dsn = 'mysql:host=' . HOSTNAME . ';dbname=' . DB_NAME;
        parent::__construct($dsn, USERNAME, PASSWORD);
        $this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
    }

    static function getInstance() {
        if (empty(self::$_instance))
            self::$_instance = new Database();
        return self::$_instance;
    }

}

